yarn patch(v3)
code:log
› yarn patch-package webchimera.js
patch-package 6.4.7
• Creating temporary folder
SyntaxError: Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in lockfile
at Parser.unexpected (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5064:11)
at Parser.parse (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5193:14)
at parse (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5262:17)
at Object.module.exports.exports.default (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:4835:96)
at Object.getPackageResolution (/Users/Project/node_modules/patch-package/dist/getPackageResolution.js:27:40)
at Object.makePatch (/Users/Project/node_modules/patch-package/dist/makePatch.js:52:63)
at /Users/Project/node_modules/patch-package/dist/index.js:52:25
at Array.forEach (<anonymous>)
at Object.<anonymous> (/Users/Project/node_modules/patch-package/dist/index.js:51:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
/Users/Project/node_modules/patch-package/dist/makePatch.js:218
throw e;
^
SyntaxError: Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in lockfile
at Parser.unexpected (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5064:11)
at Parser.parse (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5193:14)
at parse (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:5262:17)
at Object.module.exports.exports.default (/Users/Project/node_modules/@yarnpkg/lockfile/index.js:4835:96)
at Object.getPackageResolution (/Users/Project/node_modules/patch-package/dist/getPackageResolution.js:27:40)
at Object.makePatch (/Users/Project/node_modules/patch-package/dist/makePatch.js:52:63)
at /Users/Project/node_modules/patch-package/dist/index.js:52:25
at Array.forEach (<anonymous>)
at Object.<anonymous> (/Users/Project/node_modules/patch-package/dist/index.js:51:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
yarn v3に上げたところ壊れた。そもそもyarn patchでpatch-packageの機能の上位互換らしいので使ってみた
まずパッチ対象のライブラリを決める
code:sh
› yarn patch webchimera.js
➤ YN0000: Package webchimera.js@npm:0.5.2 got extracted with success!
➤ YN0000: You can now edit the following folder: /private/var/folders/2x/g2y2lrl15hv9_fmcxj4qvp740000gn/T/xfs-341dcb4a/user
➤ YN0000: Once you are done run yarn patch-commit /private/var/folders/2x/g2y2lrl15hv9_fmcxj4qvp740000gn/T/xfs-341dcb4a/user and Yarn will store a patchfile based on your changes.
/private/var/folders/2x/g2y2lrl15hv9_fmcxj4qvp740000gn/T/xfs-341dcb4a/userを開いて該当部分を触る
パッチを出す
code:sh
mkdir patches
yarn patch-commit /private/var/folders/2x/g2y2lrl15hv9_fmcxj4qvp740000gn/T/xfs-341dcb4a/user > patches/webchimera.js.patch
packagejsonの依存をいじる
code:package.json
"webchimera.js": "patch:webchimera.js@^0.5.2#patches/webchimera.js.patch",
postinstall前に依存が書き換わるので--mode=skip-buildが不要になり便利なのだなあ(詠嘆)